<?php

/**
 * @author Sonnk
 * @copyright 2013
 */

class upload_model extends CI_Model
{
	function __construct()
	{
		parent::__construct('');
	}
	public function resizeImg($image_data,$width,$height,$folder)
	{
		$listFile = explode(",",$image_data);
		$i =1;
		$configz = array();
		$this->load->library('image_lib');
		foreach($listFile as $k=>$val)
		{
			if($val!="")
			{
				
				$configz = array();
				$configz['image_library'] = 'gd2';
				$configz['source_image'] = "./files/".$folder."/".$val;
				//$configz['new_image'] =  "./files/".$folder."/thumbs/".$val;
				$configz['new_image'] =  "./files/".$folder."/".$val;
				$configz['create_thumb'] = TRUE;
				$configz['maintain_ratio'] = TRUE;
				$configz['width'] = $width;
				$configz['height'] = $height;
				$this->image_lib->initialize($configz);
				$this->image_lib->resize();
				$this->image_lib->clear();
				$i++;
			}
	
		}
	}
	public function set_upload_options()
	{   
		$config = array();
		$config['allowed_types'] = 'jpg|jpeg|gif|png';
		$config['upload_path'] = './files/thanhvien/';
		$config['encrypt_nam']      = 'TRUE';
		$config['remove_spaces']     = TRUE;
		$config['max_size']     = 1024;
		//$config['max_width']     = 650;
		//$config['max_height']     = 400;
		return $config;
	}
}
?>
